package com.Customer.service.impl;

import com.Customer.entity.Customer;
import com.Customer.mapper.CustomerMapper;
import com.Customer.service.CustomerService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 客户信息 业务逻辑实现类
 */
@Service
@Transactional
public class CustomerServiceImpl implements CustomerService {

    @Resource
    public CustomerMapper customerMapper;

    /**
     * 添加客户信息
     * @param customer
     * @return
     */
    @Override
    public boolean doAddCustomerInfo(Customer customer) {
        // 检查客户信息是否存在
        if (customerMapper.doGetCustomerInfo(customer) == null) {
            // 开始添加客户信息
            return customerMapper.doAddCustomerInfo(customer) != 0;
        }
        return false;
    }

    /**
     * 修改客户信息
     * @param customer
     * @return
     */
    @Override
    public boolean doModifyCustomerInfo(Customer customer) {
        return customerMapper.doModifyCustomerInfo(customer) != 0;
    }

    /**
     * 删除客户信息
     * @param customer
     * @return
     */
    @Override
    public boolean doDeleteCustomerInfo(Customer customer) {
        return customerMapper.doDeleteCustomerInfo(customer) != 0;
    }

    /**
     * 获取客户信息
     * @param customer
     * @return
     */
    @Override
    public Customer doGetCustomerInfo(Customer customer) {
        return customerMapper.doGetCustomerInfo(customer);
    }

    /**
     * 获取客户列表
     * @return
     */
    @Override
    public List<Customer> doGetCustomerInfoList() {
        return customerMapper.doGetCustomerInfoList();
    }

    /**
     * 查询客户列表
     * @param customer
     * @return
     */
    @Override
    public List<Customer> doQueryCustomerInfoList(Customer customer) {
        return customerMapper.doQueryCustomerInfoList(customer);
    }

}